<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<script type="text/javascript">
			function JC(){
				var num1 = document.getElementById("num").value;
				var num2 = parseInt(num1);
				if(num2 < 0){
					sp.innerHTML = "负数没有阶乘";
				}else if(num2 == 0){
					sp.innerHTML = 1;
				}else{
					var result = 1;
					for(var i = num2;i >= 1;i--){
						result = result*i;
					}
					sp.innerHTML = result;
				}
			}
		</script>
	</head>
	<body>
		<input type="text" id="num" />
		<input type="button" onclick="JC()" value="阶乘"/>
		=
		<span id="sp">
		</span>
	</body>
</html>
